home *** CD-ROM | disk | FTP | other *** search
/ Gold Medal Software 3 / Gold Medal Software - Volume 3 (Gold Medal) (1994).iso / prog / tge131.arj / SIMPLE.CPP < prev    next >
C/C++ Source or Header  |  1994-03-05  |  3KB  |  119 lines

  1. //*************************************************************************
  2. //* Program:  SIMPLE.CPP                          *
  3. //*                                      *
  4. //* Purpose:  This program does almost nothing when it is run; it is not  *
  5. //*          intended to be run, but as an example in source code form   *
  6. //*          of how to interface to TGE's various features.  The setup() *
  7. //*          function illustrates how to initialize these features, and  *
  8. //*          demo() illustrates briefly how to use them.          *
  9. //*************************************************************************
  10.  
  11. #include <conio.h>
  12. #include <stdio.h>
  13. #include <stdlib.h>
  14. #include "..\include\tge.h"
  15. #include "..\include\tgemouse.h"
  16. #include "..\include\varfont.h"
  17. #include "..\include\vcoord.h"
  18.  
  19. //*** #defines
  20. #define DRIVERNAME    "320X200.DRV"
  21. #define FONTNAME        "BIGTEXT.FNT"
  22.  
  23. //*** Function prototypes
  24. void setup(void);
  25. void demo(void);
  26.  
  27. //*** Global data
  28. VariableFont font;
  29. VirtualCoord virtScreen;
  30. int mouseExists;
  31.  
  32.  
  33. //*****
  34. //***** Program start
  35. //*****
  36.  
  37. void main(void)
  38. {
  39.   //*** Set things up
  40.   setup();
  41.  
  42.   //*** Run the demo
  43.   demo();
  44.  
  45.   //*** Restore text mode and quit
  46.   deInitGraphics();
  47. }
  48.  
  49.  
  50. //*****
  51. //***** General setup
  52. //*****
  53.  
  54. void setup(void)
  55. {
  56.   //*** Load the driver
  57.   if (loadGraphDriver(DRIVERNAME) != TGE_SUCCESS)
  58.   {
  59.     printf("Error loading driver %s; aborting.\n\n", DRIVERNAME);
  60.     exit(1);
  61.   }
  62.  
  63.   //*** Initialize graphics mode
  64.   if (!initGraphics())
  65.   {
  66.     printf("Unable to initialize graphics hardware; aborting.\n\n");
  67.     exit(1);
  68.   }
  69.  
  70.   //*** Load the font
  71.   if (!font.load(FONTNAME))
  72.   {
  73.     deInitGraphics();
  74.     printf("Error loading font file %s; aborting.\n\n", FONTNAME);
  75.     exit(1);
  76.   }
  77.  
  78.   //*** Initialize virtual coordinate system
  79.   virtScreen.virtParams(1023, 767);
  80.   virtScreen.realParams(OUTMAXX, OUTMAXY);
  81.  
  82.   //*** Set up the mouse
  83.   if ((mouseExists=resetMouse()) != 0)        // is mouse available?
  84.   {
  85.     initNewMouse();                // yes, initialize it
  86.     setHorizLimitsMouse(0, OUTMAXX);
  87.     setVertLimitsMouse(0, OUTMAXY);
  88.     setPosMouse(OUTMAXX/2, OUTMAXY/2);
  89.     setupMousePointer(BIG_ARROW_POINTER);
  90.     atexit(deInitNewMouse);
  91.   }
  92. }
  93.  
  94.  
  95. //*****
  96. //***** Silly little demo function
  97. //*****
  98.  
  99. void demo(void)
  100. {
  101.   unsigned blue;
  102.  
  103.   //*** Use colourCloseTo()
  104.   blue = colourCloseTo(0, 0, 200);
  105.  
  106.   //*** Use the virtual coordinate system
  107.   ellipse(OUTMAXX/2, OUTMAXY/2, virtScreen.realX(340), virtScreen.realY(170), blue);
  108.  
  109.   //*** Use the VariableFont class
  110.   font.put(0, 0, "Press a key to quit...");
  111.  
  112.   //*** Use the mouse
  113.   if (mouseExists)
  114.     showMouse();
  115.  
  116.   //*** Get a key, then return
  117.   getch();
  118. }
  119.